/***************************************************************
 * Name:      GanitSheetsMain.h
 * Purpose:   Defines Application Frame
 * Author:    Milind Gupta (milind.gupta@gmail.com)
 * Website:   https://code.google.com/p/ganitsheets/
 * Created:   2011-02-12
 * Copyright: Milind Gupta ()
 * License:   Apache License 2.0
 **************************************************************/

#ifndef GANITSHEETSMAIN_H
#define GANITSHEETSMAIN_H

#include <wx/notebook.h>
#include <wx/splitter.h>
#include <wx/grid.h>
#include "Globals.h"
#include "Structures.h"
#include "GanitSheetsApp.h"

// Class for the main software frame
class GanitSheetsFrame: public wxFrame, public luaObj
{
    public:
        // Constructor and desctructor
        GanitSheetsFrame(wxWindow* parent, class GanitSheetsApp *parentApp, \
                wxWindowID id = -1, unsigned long logLength = logLength);
        virtual ~GanitSheetsFrame();
        void addLogMsg(std::string Msg);
        int LuaScriptCall(int funcIndex);   // Defining the virtual function in luaObj

        unsigned long logLines; // To indicate how many lines to keep in the log text box

    private:
        // Member Objects
        GanitSheetsApp *parentApp;      // Parent creation app pointer
        wxMenuBar *menuMainGS;          // Main menu bar
        wxNotebook* sheetsBook;         // sheetsBook: for spreadsheets
        wxNotebook* commandBook;        // commandBook for commandline log and data entry
        wxSplitterWindow* splitWindowGS;// Splitter window to display the 2 notebooks
        wxSplitterWindow* splitLogCommands;// Splitter window to The Log and Commands
        wxTextCtrl* TextLog;            // Output Log Text Box
        wxTextCtrl* TextComm;           // Immediate Lua commands entry Text Box
        wxTextCtrl* TextData;           // Data entry text box
        wxPanel* PanelLogComm;          // Panel for the Log Text Box
        wxPanel* PanelComm;             // Panel for Command box and buttons
        wxPanel* PanelData;             // Panel for the Data entry text box
        wxBoxSizer* BoxSizerLogComm;    // Box Sizer for the PanelLogComm
        wxBoxSizer* BoxSizerComm;        // Box Sizer for the TextComm Text Box and associated buttons
        wxBoxSizer* BoxSizerCommButtons;// Box Sizer fot the Command Buttons
        wxBoxSizer* BoxSizerData;       // Box Sizer for the TextData Text Box
        wxButton* ButtonExec;            // Button the execute program in the Command window
        wxButton* ButtonClear;          // Button to clear the Command Box

        // id manager instance
        idList *frameIDs;
        // Spreadsheet manager instance
        spreadSheetList *spSheets;

        // Lua API exposed
        // Enumerate all the API functions
        enum GSFrameAPI
        {
            DEBUG = 0,
            ADDLOGMSG = 1,   // void addLogMsg(std::string Msg);
            CREATEMENU = 2,
            ADDSHEET = 3,
            ABOUT = 99,
            QUIT = 100         //
        };

        // Lua API Table
        static luaAPIStruct luaAPITable[], luaStaticAPITable[];

        // Event Handler function definitions
        void OnButtonClearClick(wxCommandEvent& event);
        void OnButtonExecClick(wxCommandEvent& event);
        void menuEventHandler(wxCommandEvent& event);
        void createMenu();
        wxMenu *createSubMenu(int &numOfItems);
        void OnQuit(wxCommandEvent& event);
        void OnAbout(wxCommandEvent& event);
        void quit();
        void about();
        spreadSheet* addSheet(shtSize *SheetSize);
};


#endif
